Błędne działanie wskaźnika - prośba o pomoc

O jezykach programowania w platformach i nie tylko.
Awatar użytkownika
klonmarcin
Maniak
Maniak
Posty: 3869
Rejestracja: 23 paź 2008, 15:10

Błędne działanie wskaźnika - prośba o pomoc

Nieprzeczytany post autor: klonmarcin »

Witam,

Czy istnieje możliwość aby ten wskaźnik działał poprawnie u brokera z 5cio cyfrowym kwotowaniem?

Wskaźnik oblicza wielkość lota przy danym sl i ryzyku biorąc pod uwagę aktualny stan konta.

Co trzeba zrobić aby go przerobić na 5cio cyfrowe kwotowanie - o ile jest taka możliwość?

Kod: Zaznacz cały

//+------------------------------------------------------------------+
//|                                              Monay Managment.mq4 |
//|                                   Copyright © 2010, Cisco Press. |
//|                                        error.detection@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Cisco Press."
#property link      "error.detection@gmail.com"

#property indicator_chart_window
#property indicator_buffers 2
extern color indicator_clr1= Yellow;
extern color indicator_clr2= MediumSpringGreen;
extern int Odlewej=30;

double       SL=6;//stoploss początkowy
extern double    Risk=0.02;
extern int       Order.No=1;
extern int       Position =1;
int Fontsize=10;

//----------time
extern int corner=1;
extern int x=1;
extern int y=370;
extern string type="Arial Black";
extern int size=13;
extern color colour=White;
extern bool back=true;
//-------------


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("lot");
   ObjectDelete("lot1");
   ObjectDelete("lot3");
   ObjectDelete("lot4");
   ObjectDelete("lot5");
   ObjectDelete("lot6");
   ObjectDelete("lot7");
   ObjectDelete("lot8");
   ObjectDelete("lot9");
   ObjectDelete("lot10");
   ObjectDelete("lot11");
   ObjectDelete("lot12");
   ObjectDelete("lot13");
   ObjectDelete("lot14");
   ObjectDelete("lot15");
   ObjectDelete("lot16");
   ObjectDelete("lot17");
   ObjectDelete("lot18");
   ObjectDelete("lot19");
   ObjectDelete("lot20");
   ObjectDelete("lot21");
   ObjectDelete("lot22");
   ObjectDelete("lot23");
   ObjectDelete("lot24");
   ObjectDelete("lot25");
   ObjectDelete("lot26");
   ObjectDelete("lot27");
   ObjectDelete("lot28");
   ObjectDelete("lot29");
   ObjectDelete("lot30");
   ObjectDelete("lot31");
   ObjectDelete("lot32");
   ObjectDelete("lot33");
   ObjectDelete("lot34");
   ObjectDelete("lot35");
   ObjectDelete("lot36");
   ObjectDelete("lot37");
   ObjectDelete("lot38");
   ObjectDelete("lot39");
   ObjectDelete("lot40");
   ObjectDelete("lot100");
    
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
   double Spreed=(78);
//----
    DisplayText("Lot","LotSize przy ryzyku "+DoubleToStr((Risk*100),0)+"%"+", "+"SL="+DoubleToStr(SL,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,20,Position);
    DisplayText("Lot1",DoubleToStr(Lots(SL),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,20,Position);
    
    DisplayText("Lot3","SL="+DoubleToStr(SL+2,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,35,Position);
    DisplayText("Lot4",DoubleToStr(Lots(SL+2),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,35,Position);
    
    DisplayText("Lot5","SL="+DoubleToStr(SL+4,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,50,Position);
    DisplayText("Lot6",DoubleToStr(Lots(SL+4),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,50,Position);
    
    DisplayText("Lot7","SL="+DoubleToStr(SL+6,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,65,Position);
    DisplayText("Lot8",DoubleToStr(Lots(SL+6),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,65,Position);
    
    DisplayText("Lot9","SL="+DoubleToStr(SL+8,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,80,Position);
    DisplayText("Lot10",DoubleToStr(Lots(SL+8),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,80,Position);
    
    DisplayText("Lot11","SL="+DoubleToStr(SL+10,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,95,Position);
    DisplayText("Lot12",DoubleToStr(Lots(SL+10),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,95,Position);
    
    DisplayText("Lot13","SL="+DoubleToStr(SL+12,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,110,Position);
    DisplayText("Lot14",DoubleToStr(Lots(SL+12),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,110,Position);
    
    DisplayText("Lot15","SL="+DoubleToStr(SL+14,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,125,Position);
    DisplayText("Lot16",DoubleToStr(Lots(SL+14),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,125,Position);
    
    DisplayText("Lot17","SL="+DoubleToStr(SL+16,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,140,Position);
    DisplayText("Lot18",DoubleToStr(Lots(SL+16),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,140,Position);
    
    DisplayText("Lot19","SL="+DoubleToStr(SL+20,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,155,Position);
    DisplayText("Lot20",DoubleToStr(Lots(SL+20),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,155,Position);
    
    DisplayText("Lot21","SL="+DoubleToStr(SL+22,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,170,Position);
    DisplayText("Lot22",DoubleToStr(Lots(SL+22),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,170,Position);
    
    DisplayText("Lot23","SL="+DoubleToStr(SL+24,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,185,Position);
    DisplayText("Lot24",DoubleToStr(Lots(SL+24),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,185,Position);
    
    DisplayText("Lot25","SL="+DoubleToStr(SL+29,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,200,Position);
    DisplayText("Lot26",DoubleToStr(Lots(SL+29),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,200,Position);
    
    DisplayText("Lot27","SL="+DoubleToStr(SL+34,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,215,Position);
    DisplayText("Lot28",DoubleToStr(Lots(SL+34),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,215,Position);
    
    DisplayText("Lot29","SL="+DoubleToStr(SL+39,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,230,Position);
    DisplayText("Lot30",DoubleToStr(Lots(SL+39),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,230,Position);
    
    DisplayText("Lot31","SL="+DoubleToStr(SL+44,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,245,Position);
    DisplayText("Lot32",DoubleToStr(Lots(SL+44),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,245,Position);
    
    DisplayText("Lot33","SL="+DoubleToStr(SL+49,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,260,Position);
    DisplayText("Lot34",DoubleToStr(Lots(SL+49),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,260,Position);
    
    DisplayText("Lot35","SL="+DoubleToStr(SL+54,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,275,Position);
    DisplayText("Lot36",DoubleToStr(Lots(SL+54),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,275,Position);
    
    DisplayText("Lot37","SL="+DoubleToStr(SL+59,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,290,Position);
    DisplayText("Lot38",DoubleToStr(Lots(SL+59),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,290,Position);
    
    DisplayText("Lot39","SL="+DoubleToStr(SL+64,0),"Times New Roman",Fontsize,indicator_clr1,Odlewej,305,Position);
    DisplayText("Lot40",DoubleToStr(Lots(SL+64),2),"Times New Roman",Fontsize,indicator_clr2,Odlewej-25,305,Position);
    
    DisplayText("Lot100","Spread="+DoubleToStr(MarketInfo(Symbol(),MODE_SPREAD),0),"Times New Roman",Fontsize,indicator_clr1,Odlewej-15,320,Position);
    
//----

//-------Time to end
//----

   double i;
   int m,s,k;
   m=Time[0]+Period()*60-CurTime();
   i=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
   
string ss;

   switch (s)
  {
   case 0:
      ss="00"; 
      break;
   case 1:
      ss="01"; 
      break;
   case 2:
      ss="02";
      break;
   case 3:
      ss="03"; 
      break;
   case 4:
      ss="04";
      break;
   case 5:
      ss="05";
      break;
   case 6:
      ss="06";
      break;
   case 7:
      ss="07";
      break;
   case 8:
      ss="08";
      break;
   case 9:
      ss="09";
      break;
   default:
     ss=s; 
   }


   ObjectDelete("time");
   
   if(ObjectFind("time") != 0)
   {
      ObjectCreate("time", OBJ_LABEL, 0,0,0);
      ObjectSet("time", OBJPROP_COLOR, colour);    
      ObjectSet("time", OBJPROP_CORNER, corner);        
      ObjectSet("time", OBJPROP_XDISTANCE, x);          
      ObjectSet("time", OBJPROP_YDISTANCE, y);  
      ObjectSet("time", OBJPROP_BACK, back);
      ObjectSetText("time",""+m+":"+ss+"",size,type);
   }
   else
   {
   ObjectMove("time", 0,0,0);
   }


//----------------
   return(0);
  }
//+------------------------------------------------------------------+
double Lots(double SL)
   {
      double accfr= AccountFreeMargin();
      double PV=MarketInfo(Symbol(),MODE_TICKVALUE);
      double Lot = (accfr*Risk)/(SL*PV);
      if (Order.No==1)Lot=Lot;
      else Lot=Lot/Order.No;
      return (NormalizeDouble(Lot,2));
   }
//+------------------------------------------------------------------+
void DisplayText(string objname, string objtext, string fontname, int fontsize, int clr, int x, int y,int Cor)
   {
      ObjectCreate(objname,OBJ_LABEL,0,0,0);
      ObjectSetText(objname,objtext,fontsize,fontname,clr);
      ObjectSet(objname,OBJPROP_CORNER,Cor);
      ObjectSet(objname,OBJPROP_XDISTANCE,x);
      ObjectSet(objname,OBJPROP_YDISTANCE,y);
   }
//+------------------------------------------------------------------+  
Nie prowadzę szkoleń - nie sprzedaję sygnałów
No pain - No gain
Czas to pieniądz - ile jesteś w stanie go poświęcić?

https://www.youtube.com/watch?v=FLqQPZaiHvs

Rób to co kochasz, kochaj to co robisz, a nigdy nie będziesz musiał pracować...

Awatar użytkownika
kupidyn
Gaduła
Gaduła
Posty: 376
Rejestracja: 19 sty 2009, 20:51

Re: Błędne działanie wskaźnika - prośba o pomoc

Nieprzeczytany post autor: kupidyn »

tutaj masz taki sam wskanik przerobiony na kwotowanie 5cio cyfrowe

http://forex-nawigator.biz/forum/przero ... ml#p514849

JAREK67
Maniak
Maniak
Posty: 2143
Rejestracja: 13 lip 2006, 11:21

Re: Błędne działanie wskaźnika - prośba o pomoc

Nieprzeczytany post autor: JAREK67 »

klonmarcin pisze:Witam,

Czy istnieje możliwość aby ten wskaźnik działał poprawnie u brokera z 5cio cyfrowym kwotowaniem?

Wskaźnik oblicza wielkość lota przy danym sl i ryzyku biorąc pod uwagę aktualny stan konta.

Co trzeba zrobić aby go przerobić na 5cio cyfrowe kwotowanie - o ile jest taka możliwość?
Kiedyś go przerobiłem na własne potrzeby. Możesz określić ryzyko w procentach lub w kwocie. Działa z 5-cio cyfrowymi brokerami.
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.

Awatar użytkownika
klonmarcin
Maniak
Maniak
Posty: 3869
Rejestracja: 23 paź 2008, 15:10

Re: Błędne działanie wskaźnika - prośba o pomoc

Nieprzeczytany post autor: klonmarcin »

Nie wiem jak wam - ale u mnie poprawnie wyświetla wartość lota dopiero jak w parametrze Order.No wpiszę 10. Przy wartości 1 podaje 10x większego lota niż powinien.
Nie prowadzę szkoleń - nie sprzedaję sygnałów
No pain - No gain
Czas to pieniądz - ile jesteś w stanie go poświęcić?

https://www.youtube.com/watch?v=FLqQPZaiHvs

Rób to co kochasz, kochaj to co robisz, a nigdy nie będziesz musiał pracować...

JAREK67
Maniak
Maniak
Posty: 2143
Rejestracja: 13 lip 2006, 11:21

Re: Błędne działanie wskaźnika - prośba o pomoc

Nieprzeczytany post autor: JAREK67 »

klonmarcin pisze:Nie wiem jak wam - ale u mnie poprawnie wyświetla wartość lota dopiero jak w parametrze Order.No wpiszę 10. Przy wartości 1 podaje 10x większego lota niż powinien.
u mnie działa poprawnie. :roll:

ODPOWIEDZ