Download MetaTrader 5

can't get swap values

To add comments, please log in or register
sergey
254
sergey  
//----
double    swaplong,swapshort;
int spread;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  int init()
  {
   IndicatorShortName("spread/swap monitor ("+Symbol()+")");
//----
  return(0);}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
   {
      return(0);
   }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()

  {

   double x;
   x=AccountBalance()*0.005;
   spread=MarketInfo(Symbol(),MODE_SPREAD);
   swaplong=NormalizeDouble(MarketInfo(Symbol(),MODE_SWAPLONG),3);
   swapshort=NormalizeDouble(MarketInfo(Symbol(),MODE_SWAPSHORT),3);
//----
   ObjectCreate("spread/swap monitor1", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor1","Current Spread :", 9, "Arial Black", Gold);
   ObjectSet("spread/swap monitor", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor1", OBJPROP_XDISTANCE, 200);
   ObjectSet("spread/swap monitor1", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor2", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor2",DoubleToStr(spread ,0),9, "Arial Black", Gold);
   ObjectSet("spread/swap monitor2", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor2", OBJPROP_XDISTANCE, 320);
   ObjectSet("spread/swap monitor2", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor3", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor3","Buy Swap :", 9, "Arial Black", White);
   ObjectSet("spread/swap monitor3", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor3", OBJPROP_XDISTANCE, 410);
   ObjectSet("spread/swap monitor3", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor4", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor4",DoubleToStr( swaplong ,3),9, "Arial Black",  White);
   ObjectSet("spread/swap monitor4", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor4", OBJPROP_XDISTANCE, 490);
   ObjectSet("spread/swap monitor4", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor5", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor5","Sell Swap :", 9, "Arial Black", Tan);
   ObjectSet("spread/swap monitor5", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor5", OBJPROP_XDISTANCE, 590);
   ObjectSet("spread/swap monitor5", OBJPROP_YDISTANCE, 2);
//----

   ObjectCreate("spread/swap monitor6", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor6",DoubleToStr( swapshort ,3),9, "Arial Black", Tan);
   ObjectSet("spread/swap monitor6", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor6", OBJPROP_XDISTANCE, 670);
   ObjectSet("spread/swap monitor6", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor7", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor7","avg risk :", 9, "Arial Black", Pink);
   ObjectSet("spread/swap monitor7", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor7", OBJPROP_XDISTANCE, 755);
   ObjectSet("spread/swap monitor7", OBJPROP_YDISTANCE, 2);
//----
   ObjectCreate("spread/swap monitor8", OBJ_LABEL, WindowFind("spread/swap monitor ("+Symbol()+")"), 0, 0);
   ObjectSetText("spread/swap monitor8", "$ " + DoubleToStr(x,2) , 9, "Arial Black", Pink);
   ObjectSet("spread/swap monitor8", OBJPROP_CORNER, 0);
   ObjectSet("spread/swap monitor8", OBJPROP_XDISTANCE, 820);
   ObjectSet("spread/swap monitor8", OBJPROP_YDISTANCE, 2);
//----   
   
   return(0);
  }
//+------------------------------------------------------------------+

please help !

qjol
3245
qjol  
double swaplong=NormalizeDouble(MarketInfo(Symbol(),MODE_SWAPLONG),3);
double swapshort=NormalizeDouble(MarketInfo(Symbol(),MODE_SWAPSHORT),3);
sergey
254
sergey  

thanks for help

but it didn't work

zzuegg
1505
zzuegg  

your code works for me....

sergey
254
sergey  

atleast its not written for nothing ...lol

zzuegg
1505
zzuegg  

hehe, well lets, see, if you add:

Alert(MarketInfo(Symbol(),MODE_SWAPLONG));

what is the output?

sergey
254
sergey  

for me - " 0 "

zzuegg
1505
zzuegg  

Well, then there there are not much options left...

Live/Demo account? maybe on some demo account there is no swap...

sergey
254
sergey  

live account

maybe it has something to do with the broker .??

It actually worked once for some time ... but it was like half a year ago

qjol
3245
qjol  

there are brokers who have no swap, especially by demo accounts

sergey
254
sergey  

its a live account... and it used to work once but now it stopped. . lol :|

12
To add comments, please log in or register