Einzelnen Beitrag anzeigen
  #10 (permalink)  
Alt 07.03.17
ping ping ist offline
Mitglied
 
Registriert seit: Feb 2017
Beiträge: 31
ping befindet sich auf einem aufstrebenden Ast
Standard

@Tycoon,

sorry für die späte Antwort, hatte noch ein längeres Telefonat.
Ich habe dir mal schnell eine mögliche Lösung hingekritzelt.
Die Werte werden allerdings hier immer positiv dargestellt, sonst bräuchte man noch einen "long/short"-Button.

Code:
#property indicator_chart_window
#property strict
extern int SSL=50;  // SL Startabstand [Digits]
extern int STP=100; // TP Startabstand [Digits]
string     Tx="2Linien ";
double     SL,TP;
int init()
{ if(GlobalVariableCheck(Tx+"TFW"))
  { SL=GlobalVariableGet(Tx+"SL");
    TP=GlobalVariableGet(Tx+"TP");
    GlobalVariablesDeleteAll(Tx);
  }
  else
  { ObjectCreate(Tx+"LabelSL",OBJ_LABEL,ChartWindowFind(),0,0);
    ObjectSet(Tx+"LabelSL",OBJPROP_CORNER,0);
    ObjectSet(Tx+"LabelSL",OBJPROP_XDISTANCE,2);
    ObjectSet(Tx+"LabelSL",OBJPROP_YDISTANCE,12);
    ObjectSet(Tx+"LabelSL",OBJPROP_SELECTABLE,false);
    ObjectSet(Tx+"LabelSL",OBJPROP_HIDDEN,true);
    ObjectSetString(0,Tx+"LabelSL",OBJPROP_TOOLTIP,"\n");
    ObjectCreate(Tx+"LabelTP",OBJ_LABEL,ChartWindowFind(),0,0);
    ObjectSet(Tx+"LabelTP",OBJPROP_CORNER,0);
    ObjectSet(Tx+"LabelTP",OBJPROP_XDISTANCE,2);
    ObjectSet(Tx+"LabelTP",OBJPROP_YDISTANCE,27);
    ObjectSet(Tx+"LabelTP",OBJPROP_SELECTABLE,false);
    ObjectSet(Tx+"LabelTP",OBJPROP_HIDDEN,true);
    ObjectSetString(0,Tx+"LabelTP",OBJPROP_TOOLTIP,"\n");
    ObjectCreate(Tx+"LinieSL",OBJ_HLINE,0,0,Bid-SSL*MathPow(10,Digits*-1));
    ObjectSet(Tx+"LinieSL",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet(Tx+"LinieSL",OBJPROP_COLOR,Red);
    ObjectSet(Tx+"LinieSL",OBJPROP_HIDDEN,true);
    ObjectSetString(0,Tx+"LinieSL",OBJPROP_TOOLTIP,"\n");
    ObjectCreate(Tx+"LinieTP",OBJ_HLINE,0,0,Bid+STP*MathPow(10,Digits*-1));
    ObjectSet(Tx+"LinieTP",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet(Tx+"LinieTP",OBJPROP_COLOR,Blue);
    ObjectSet(Tx+"LinieTP",OBJPROP_HIDDEN,true);
    ObjectSetString(0,Tx+"LinieTP",OBJPROP_TOOLTIP,"\n");
    rechnen();
  }
  return(0);
}
void OnChartEvent(const int Id,const long &x,const double &y,const string &S)
{ if(Id==CHARTEVENT_OBJECT_DRAG)
    if(S==Tx+"LinieSL"||S==Tx+"LinieTP")
      rechnen();
}
int start()
{ rechnen();
  return(0);
}
void OnDeinit(const int R)
{ if(R!=REASON_CHARTCHANGE)
    ObjectsDeleteAll(0,Tx);
  else
  { GlobalVariableSet(Tx+"TFW",1);
    GlobalVariableSet(Tx+"SL",SL);
    GlobalVariableSet(Tx+"TP",TP);
  }
}
void rechnen()
{ SL=ObjectGet(Tx+"LinieSL",OBJPROP_PRICE1);
  if(Bid>SL)
    SL=Bid-SL;
  else
    SL-=Bid;
  ObjectSetString(0,Tx+"LabelSL",OBJPROP_TEXT,"SL-Abstand: "+DoubleToStr(SL,Digits));
   TP=ObjectGet(Tx+"LinieTP",OBJPROP_PRICE1);
  if(Bid>TP)
    TP=Bid-TP;
  else
    TP-=Bid;
  ObjectSetString(0,Tx+"LabelTP",OBJPROP_TEXT,"TP-Abstand: "+DoubleToStr(TP,Digits));
}
oder als Download: Anhang 2731


PS.: wie geht das hier, dass man den Dateinamen des Anhangs sieht und nicht die komische Nummer (2731)?