MQL4 (newbie programming)

 

Hi, I am learning programming mql4 as newbie

I know only simple basic. but deep advanced that i still not sure.

My project is

1) counted total iBar in select Date/Time from Start to End. I able to do this.

2) counted total of range = iHigh - iLow = total range. I able to do this.

3) Calculated Pips - Total range*Digits. I able to do this.

But

4) total iBar of Pips from Start to End....

Example Pips each of one iBar from Start to End need calulcate total Pips

(I don't know how to do) I think something relate loop or for or if else??? I dun understand how to work.


Here of code


extern datetime StartTime;

extern datetime EndTime;



int shift;

int shift1;



double iRangeHigh;

double iRangeLow;

double TotaliRangeBar;

double TotalPips;



double iRangeHigh1;

double iRangeLow1;

double TotaliRangeBar1;

double TotalPips1;



int OnInit()

  {



datetime choicetime= StartTime;

shift=iBarShift("EURUSD",PERIOD_M1,choicetime);

Print("Index of the bar for the Start time ",TimeToStr(choicetime)," is ",shift);

iRangeHigh=iHigh("EURUSD",PERIOD_M1,shift);

iRangeLow=iLow("EURUSD",PERIOD_M1,shift);

TotaliRangeBar=iRangeHigh-iRangeLow;

Print("----- Start Time of iHigh is ",iRangeHigh,"----- Start Time of iLow is ",iRangeLow,"----- Total range of iBar is ",TotaliRangeBar);

TotalPips=TotaliRangeBar*10000;

Print("Total Pips is ",TotalPips);



datetime endchoicetime=EndTime;

shift1=iBarShift("EURUSD",PERIOD_M1,endchoicetime);

Print("Index of the bar for the End time ",TimeToStr(endchoicetime)," is ",shift1);

iRangeHigh1=iHigh("EURUSD",PERIOD_M1,shift1);

iRangeLow1=iLow("EURUSD",PERIOD_M1,shift1);

TotaliRangeBar1=iRangeHigh1-iRangeLow1;

Print("----- End Time of iHigh is ",iRangeHigh1,"----- End Time of iLow is ",iRangeLow1,"----- Total range of iBar is ",TotaliRangeBar1);

TotalPips1=TotaliRangeBar1*10000;

Print("Total Pips is ",TotalPips1);



int countedtotalbar;

countedtotalbar = shift-shift1;

Print("Total of counted bars is ", countedtotalbar);

Print("Digit of curreny is ",Digits);



//---

   return(INIT_SUCCEEDED);

  }
 
3) Calculated Pips - Total range*Digits. I able to do this.

Multiplying a change in price by 5 doesn't convert it to PIPs.

PIP, Point, or Tick are all different in general.
          What is a TICK? - MQL4 programming forum

Unless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
          How to manage JPY pairs with parameters? - MQL4 programming forum
          Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

 
William Roeder:

Multiplying a change in price by 5 doesn't convert it to PIPs.

PIP, Point, or Tick are all different in general.
          What is a TICK? - MQL4 programming forum

Unless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
          How to manage JPY pairs with parameters? - MQL4 programming forum
          Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

Hi William,

Now I getting headache by read this.... Too complicate... I think I am poor english or I am newbie stock market and programming.... I guess I need to study more but headache already.

I think my code way is wrong... or not sure...



extern double lotsize=0;

extern double amount=0;


double BuyValue;

double SellValue;

double TotalChangeLoss;

double TotalChangeProfit;

double PerPipValue;

double PerPipValue1;


int OnInit()

  {

//--- indicator buffers mapping



Print("Current Marketinfo Bid ",MarketInfo("EURUSD",MODE_BID));

Print("Current Marketinfo Ask ",MarketInfo("EURUSD",MODE_ASK));

Print("Lot Size is ",lotsize,". Base of Currency Amount EUR Dollar is ",DoubleToStr(amount,0));


BuyValue=lotsize*amount*MarketInfo("EURUSD",MODE_BID);

SellValue=lotsize*amount*MarketInfo("EURUSD",MODE_ASK);

Print("Bid Value is ",BuyValue);

Print("Ask Value is ",SellValue);

   

TotalChangeLoss=BuyValue-SellValue;

TotalChangeProfit=SellValue-BuyValue;

Print("Total Change Loss is $",DoubleToStr(TotalChangeLoss,0)," USD Dollar");

Print("Total Change Profit is $",DoubleToStr(TotalChangeProfit,0)," USD Dollar");  


PerPipValue=(TotalChangeLoss/(BuyValue-SellValue));

Print("Per Pip Value is $",DoubleToStr(PerPipValue,0)," Loss");

PerPipValue1=(TotalChangeProfit/(SellValue-BuyValue));

Print("Per Pip Value is $",DoubleToStr(PerPipValue1,0)," Profit");


//---

   return(INIT_SUCCEEDED);

  }

 
Jackson0000: Now I getting headache by read this.... Too complicate... I think I am poor english or I am newbie stock market and programming.... I guess I need to study more but headache already.

I think my code way is wrong... or not sure...

  1. Please edit your (previous) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. No question or problem stated. No reply needed.
Reason: