Hi,
need some help with my code
I'm trying to do 2 things, trail my open position when it goes into profit by x pips and execute trailingpositions routine
then when price hits + 30 (level set externally by LevelTargetInProfit) then use a different routine which is trailingpositions2
but it will not work for me :-/ It executes routine 2 above 30 pips so I don't have a SL to start whereas I want it to start at -30 and move the SL each time price goes +1
//+------------------------------------------------------------------+
//| Trailing levels |
//+------------------------------------------------------------------+
void CheckPriceAboveorBelowLevel() {
int pr=ProfitPosition(), sl=StopLossInPoint();
int sp=MarketInfo(OrderSymbol(), MODE_SPREAD);
if (pr<LevelTargetInProfit && pr>=-3000 ) {
TrailingPositions();
return;
}
if (pr>LevelTargetInProfit ) {
TrailingPositions2();
return;
}
}
what am I doing wrong ? I need it to trail immediately?
Must I set a SL to start or will MT4 it apply one.
need some help with my code
I'm trying to do 2 things, trail my open position when it goes into profit by x pips and execute trailingpositions routine
then when price hits + 30 (level set externally by LevelTargetInProfit) then use a different routine which is trailingpositions2
but it will not work for me :-/ It executes routine 2 above 30 pips so I don't have a SL to start whereas I want it to start at -30 and move the SL each time price goes +1
//+------------------------------------------------------------------+
//| Trailing levels |
//+------------------------------------------------------------------+
void CheckPriceAboveorBelowLevel() {
int pr=ProfitPosition(), sl=StopLossInPoint();
int sp=MarketInfo(OrderSymbol(), MODE_SPREAD);
if (pr<LevelTargetInProfit && pr>=-3000 ) {
TrailingPositions();
return;
}
if (pr>LevelTargetInProfit ) {
TrailingPositions2();
return;
}
}
what am I doing wrong ? I need it to trail immediately?
Must I set a SL to start or will MT4 it apply one.
Attached File(s)