Coding help - page 747

 
I hope this screen show exacly what I want :)
Files:
 
skyler1234321:
I hope this screen show exacly what I want :)

If you are using HighLowCandle > 0, then it is absed on a closed candle.

Set the UseBarDirection to true and check it then

 

Yes i have it in settings. There are my settings what i tested

 

Meybe in code there is something wrong. Could you check inside? 

Files:
2.PNG  25 kb
 
cja:

Is there any simple way of accessing MT5 indicator data for an on chart display. I know that initially when MT5 first came out the code was quite complicated for just a simple indicator and I am hopeful with the latest version of MT5 something may have changed?

 For example if I want to show a MA cross on chart object display with MT4 I use

 double slow_MA =  iMA(Symbol(),0,100,0,MA_MODE,MA_PRICE,0);  

 double fast_MA =  iMA(Symbol(),0,35,0,MA_MODE,MA_PRICE,0); 

if (ma_fast > ma_slow){ col = clrLime;}

if (ma_fast < ma_slow) {col = clrRed;}

else {col = clrGray;}


is there any simple equivalent in MT5? or do I have to write untold lines of code to access this information?

Hi cja

First to thanks for your visiting back TSD in 2017 then Happy new year to you as you are very rare visiting tsd but very old,senior and expert member :)

regards

 

I'm trying to change this Trailing with Step routine.
I need to move from stoploss and not from the buy/sell entrance...

for example: (BUY operation)

StopLoss: 250 (in points)
Traling      :150 (in points)
TralingStep: 50 (in points)
===========

BUY Entrance=> 1000 
StopLoss=>750   (=1000-250)

================
First Price Change) Price moved to: 1150 

(I don't need this.. ;-( )
Trailing is moving my stoploss to "buy_entrance"  =>1000

(But I need this)
Trailing should move my stoploss to => 800 (=StopLoss+Trailingstep)

Second Price Change) Price moved to: 1300
Trailing show be moved to=> 950  (=StopLoss+Trailingstep)


the actual code use trailing and trailing step but I need to modify it...
when (price moved) the trailing in points is reached and it use trailing step to move the stop loss but the actual code
move the stoploss to Entry point of the operation (and I don't want this)

I need:

when BUY is opened: if the trailing is reached , the trailing step should be subtracted from the actual stoploss. (NewStopLoss = LastStoploss - TrailingStep)
when SELL is opened: if the trailing is reached , the trailing step should be added from the actual stoploss. (NewStopLoss = LastStoploss +TrailingStep)

#include <Trade/Trade.mqh>
#include <Trade/SymbolInfo.mqh>
#include <Trade/PositionInfo.mqh>
CTrade Trade;
CSymbolInfo Sym;
CPositionInfo Pos;

int
 Trailing = 150;
int TrailingStep = 25;

void fSimpleTrailingStep(){   //mt5
   if(Trailing<=0){
      return;
   }         
   if(!Pos.Select(_Symbol)){
      return;
   }         
   if(!Sym.RefreshRates()){
      return;  
   }   
   double nsl,tmsl,psl,newstop;  
   switch(Pos.PositionType()){
      case POSITION_TYPE_BUY:
         nsl=Sym.NormalizePrice(Sym.Bid()-_Point*Trailing);
            if(nsl>=Sym.NormalizePrice(Pos.PriceOpen())){
               //if(nsl>Sym.NormalizePrice(Pos.StopLoss())){
               if(nsl>=Sym.NormalizePrice(Pos.StopLoss()+_Point*TrailingStep)){  //////////////
                  //tmsl=Sym.NormalizePrice(Sym.Bid()-_Point*Sym.StopsLevel());
                   tmsl=Sym.NormalizePrice(Sym.Bid()-_Point*Sym.StopsLevel());
                     if(nsl<tmsl){
                        //Trade.PositionModify(_Symbol,nsl,Pos.TakeProfit());
                        newstop=Sym.NormalizePrice(Pos.StopLoss()+_Point*TrailingStep);
                        Trade.PositionModify(_Symbol,newstop,Pos.TakeProfit());
                        Print ("(BUY) Trailing :"+Pos.StopLoss());
                     }
               }
            }
      break;
      case POSITION_TYPE_SELL:
         nsl=Sym.NormalizePrice(Sym.Ask()+_Point*Trailing);
            //if(nsl<=Sym.NormalizePrice(Pos.PriceOpen())){             
            if(nsl<=Sym.NormalizePrice(Pos.PriceOpen())-_Point*TrailingStep){   //////////////
               psl=Sym.NormalizePrice(Pos.StopLoss());
                  if(nsl<psl || psl==0){
                     tmsl=Sym.NormalizePrice(Sym.Ask()+_Point*Sym.StopsLevel());
                        if(nsl>tmsl){
                           newstop=Sym.NormalizePrice(Pos.StopLoss()-_Point*TrailingStep);
                           //Trade.PositionModify(_Symbol,nsl,Pos.TakeProfit());
                           Trade.PositionModify(_Symbol,newstop,Pos.TakeProfit());
                           Print ("(SELL) Trailing :"+Pos.StopLoss());
                        }
                  }
            }      
      break;
   }
}
 
baraozemo:

I'm trying to change this Trailing with Step routine.
I need to move from stoploss and not from the buy/sell entrance...

for example: (BUY operation)

StopLoss: 250 (in points)
Traling      :150 (in points)
TralingStep: 50 (in points)
===========

BUY Entrance=> 1000 
StopLoss=>750   (=1000-250)

================
First Price Change) Price moved to: 1150 

(I don't need this.. ;-( )
Trailing is moving my stoploss to "buy_entrance"  =>1000

(But I need this)
Trailing should move my stoploss to => 800 (=StopLoss+Trailingstep)

Second Price Change) Price moved to: 1300
Trailing show be moved to=> 950  (=StopLoss+Trailingstep)


the actual code use trailing and trailing step but I need to modify it...
when (price moved) the trailing in points is reached and it use trailing step to move the stop loss but the actual code
move the stoploss to Entry point of the operation (and I don't want this)

I need:

when BUY is opened: if the trailing is reached , the trailing step should be subtracted from the actual stoploss. (NewStopLoss = LastStoploss - TrailingStep)
when SELL is opened: if the trailing is reached , the trailing step should be added from the actual stoploss. (NewStopLoss = LastStoploss +TrailingStep)

#include <Trade/Trade.mqh>
#include <Trade/SymbolInfo.mqh>
#include <Trade/PositionInfo.mqh>
CTrade Trade;
CSymbolInfo Sym;
CPositionInfo Pos;

int
 Trailing = 150;
int TrailingStep = 25;

void fSimpleTrailingStep(){   //mt5
   if(Trailing<=0){
      return;
   }         
   if(!Pos.Select(_Symbol)){
      return;
   }         
   if(!Sym.RefreshRates()){
      return;  
   }   
   double nsl,tmsl,psl,newstop;  
   switch(Pos.PositionType()){
      case POSITION_TYPE_BUY:
         nsl=Sym.NormalizePrice(Sym.Bid()-_Point*Trailing);
            if(nsl>=Sym.NormalizePrice(Pos.PriceOpen())){
               //if(nsl>Sym.NormalizePrice(Pos.StopLoss())){
               if(nsl>=Sym.NormalizePrice(Pos.StopLoss()+_Point*TrailingStep)){  //////////////
                  //tmsl=Sym.NormalizePrice(Sym.Bid()-_Point*Sym.StopsLevel());
                   tmsl=Sym.NormalizePrice(Sym.Bid()-_Point*Sym.StopsLevel());
                     if(nsl<tmsl){
                        //Trade.PositionModify(_Symbol,nsl,Pos.TakeProfit());
                        newstop=Sym.NormalizePrice(Pos.StopLoss()+_Point*TrailingStep);
                        Trade.PositionModify(_Symbol,newstop,Pos.TakeProfit());
                        Print ("(BUY) Trailing :"+Pos.StopLoss());
                     }
               }
            }
      break;
      case POSITION_TYPE_SELL:
         nsl=Sym.NormalizePrice(Sym.Ask()+_Point*Trailing);
            //if(nsl<=Sym.NormalizePrice(Pos.PriceOpen())){             
            if(nsl<=Sym.NormalizePrice(Pos.PriceOpen())-_Point*TrailingStep){   //////////////
               psl=Sym.NormalizePrice(Pos.StopLoss());
                  if(nsl<psl || psl==0){
                     tmsl=Sym.NormalizePrice(Sym.Ask()+_Point*Sym.StopsLevel());
                        if(nsl>tmsl){
                           newstop=Sym.NormalizePrice(Pos.StopLoss()-_Point*TrailingStep);
                           //Trade.PositionModify(_Symbol,nsl,Pos.TakeProfit());
                           Trade.PositionModify(_Symbol,newstop,Pos.TakeProfit());
                           Print ("(SELL) Trailing :"+Pos.StopLoss());
                        }
                  }
            }      
      break;
   }
}
Your initial start always must be from the initial buy/sell entrance (there is no other available criteria)
 

Dearest MLADEN

Timmy and me are trying to play (copy/paste) with an simple EA with basic sell/buy on trend change, based on "averages - mtf - alerts  8.7" , as we both zero in coding matters,plz help and guide,how to code (icustom) for this averages ver.

regards



     double Averages_trend_current  = iCustom(NULL,0,"averages - mtf - alerts  8.7",PERIOD_CURRENT,AveragePeriod,AveragePrice,AverageMethod,DoubleSmoothedAverage,AdaptiveAverage,FilterPeriod,FilterOn,BarToUse);

     double Averages_trend_previous = iCustom(NULL,0,"averages - mtf - alerts  8.7",PERIOD_CURRENT,AveragePeriod,AveragePrice,AverageMethod,DoubleSmoothedAverage,AdaptiveAverage,FilterPeriod,FilterOn,BarToUse+1);


 
mntiwana:

Dearest MLADEN

Timmy and me are trying to play (copy/paste) with an simple EA with basic sell/buy on trend change, based on "averages - mtf - alerts  8.7" , as we both zero in coding matters,plz help and guide,how to code (icustom) for this averages ver.

regards



     double Averages_trend_current  = iCustom(NULL,0,"averages - mtf - alerts  8.7",PERIOD_CURRENT,AveragePeriod,AveragePrice,AverageMethod,DoubleSmoothedAverage,AdaptiveAverage,FilterPeriod,FilterOn,BarToUse);

     double Averages_trend_previous = iCustom(NULL,0,"averages - mtf - alerts  8.7",PERIOD_CURRENT,AveragePeriod,AveragePrice,AverageMethod,DoubleSmoothedAverage,AdaptiveAverage,FilterPeriod,FilterOn,BarToUse+1);


Something is wrong with the buffers , i used buffer : 2 for buy and both buffer  3 and 4 for sell , but everything triggers all of the time , tried only to use buffer 2 for buy and buffer 3 for sell , but the same thing happened .
 
timmyhanke:
Something is wrong with the buffers , i used buffer : 2 for buy and both buffer  3 and 4 for sell , but everything triggers all of the time , tried only to use buffer 2 for buy and buffer 3 for sell , but the same thing happened .

Nothing wrong with buffers. Use buffer 9 : 1 for trend up, -1 for trend down

 

Dear Mr Mladen,


I need an histogramt indicator  for my strategy trading, right now I use XB4 indicator and Bandit strategy indicator. but they don't have alert and notification send to email or to my android MT4.

do you have  modified indicator XB4d ndicator that have alert send email  and notification that send to android mobil phone. if histogram change colour blue to red, or red to blue on the first bar.

and  histogram trend session from Bandid system indicator, that change colour from blue to red,or red to blue, first colour of changing trend.

could you help me about this indicator Mr Mladen.




regards,

Samuel

Files:
bandit.PNG  56 kb
XB4.PNG  46 kb