Try to make a smalll modification in the MA_Advisor

Moderator: admin

Try to make a smalll modification in the MA_Advisor

Postby surfandturf » Sun Mar 11, 2012 11:49 am

Hello,
I made a small adjustment to the MA Advisor. I used the editor and changed what I wanted to change and renamed the file, since I don´t want to have a conflict with the original which I use, too. I run it through the strategy debugger, then I copied the file in the folder of strategies/standard. Do I need to compile or can I just copy the file? When trying to open the strategy in the marketscope, the message -- try to attempt nil to a global index -- appeared and I couldn´t load the file to my strategies. Do I have do make a copy of the RC file and give it the same name as I have used for the adjusted strategy? How do I make small changes to an existing program properly?

What I wanted to achieve was, when I use both sides to trade (long and short), that the opposite trade doesn´t not close the trade before. E.g. the MVA opens a long trade and then a short, in this instance the long trade is automatically closed. I don´t want this to happen. Therefore, I removed under the -- buy condition met -- in the code, the line " close ("S") -- closes all existing shorts --, and under -- sell condition met -- the line close ("B") -- closes all existing longs. Can you help me out?

Thanks

Here the extract of code I tried to change:

-- buy condition met (fast crosses over slow)
if CANTRADE then
close("S"); -- closes all existing shorts on the account enter("B"); -- and the enter long
end
terminal:alertMessage(TICKSRC:instrument(), TICKSRC[NOW], name .. ":" .. BUY, TICKSRC:date(NOW));
if PLAY then
terminal:alertSound(SOUND, RECURRENTSOUND);
end

if SENDEMAIL then
terminal:alertEmail(EMAIL, name .. ":" .. BUY, FormatEmail(TICKSRC, NOW, BUY));
end
elseif core.crossesUnder(FMADATA, SMADATA, p - FMASHIFT, p - SMASHIFT) and (ALLOWEDSIDE == "Both" or ALLOWEDSIDE == "Sell") then
-- sell condition met (slow crosses over fast)
if CANTRADE then
close("B"); -- closes all existing longs on the account enter("S"); -- and the enter short
end
surfandturf
 
Posts: 25
Joined: Mon Jan 09, 2012 10:16 am

Re: Try to make a smalll modification in the MA_Advisor

Postby sunshine » Mon Mar 12, 2012 1:23 am

Hi,

Do I have do make a copy of the RC file and give it the same name as I have used for the adjusted strategy? How do I make small changes to an existing program properly?

Please read this post:
viewtopic.php?f=25&t=13350#p26033
I hope it helps.

What I wanted to achieve was, when I use both sides to trade (long and short), that the opposite trade doesn´t not close the trade before. E.g. the MVA opens a long trade and then a short, in this instance the long trade is automatically closed. I don´t want this to happen. Therefore, I removed under the -- buy condition met -- in the code, the line " close ("S") -- closes all existing shorts --, and under -- sell condition met -- the line close ("B") -- closes all existing longs. Can you help me out?


Note that this change will only work on non-US accounts. Do not forget to set Stop and Limit parameters since it is only condition to close positions.
Just in case, the modified version of the strategy is attached.
Attachments
ma_advisor_modified.lua
(17.36 KiB) Downloaded 529 times
ma_advisor_modified.lua.rc
(34.46 KiB) Downloaded 526 times
sunshine
 


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 74 guests