Hello Apprentice
Could you please develop this simple strategy using the CMAC indicator?
Much appreciated!
Strategy parametersAllowed Side = Both
Allow Multiple Positions = True
Timeframe = 1 minute
Price soruce = Bid
Price type = Close
CMAC parametersPeriod = Let user choose
Calculation mode = Static
Calculation type = "Percentage" (2)
Percentage range = Let user choose
Pip range = Let user choose
Buy condition((source.open( 0 ) > CMAC.Bottom( 0 )) .and. (source.close( 0 ) < CMAC.Bottom( 0 )))
Sell condition((source.open( 0 )<CMAC.Top( 0 )) .and. (source.close( 0 ) > CMAC.Top( 0 )))
Close long positions(
getBuyNetPL( symbol ) > var)
Close short positions(
getSellNetPL( symbol ) > var)
Functions- Code: Select all
function getBuyNetPL(sInstrument)
local res;
checkSummaryRow(sInstrument);
res = mSummaries[sInstrument];
if res == nil then
return 0;
else
return res.BuyNetPL;
end
end
- Code: Select all
function getSellNetPL(sInstrument)
local res;
checkSummaryRow(sInstrument);
res = mSummaries[sInstrument];
if res == nil then
return 0;
else
return res.SellNetPL;
end
end