How to code? - page 195

 
kipper:
What is happening is the program does everything expect when the figure is under 15 it stays BLUE, not sure what I have done wrong, I am hoping someone could shed some light for me.

Here is the code I have 4 the colors

Try this:

if(sym_1 85) color_1 = Red; else color_1 = Blue;

if(sym_2 85) color_2 = Red; else color_2 = Blue;

if(sym_3 85) color_3 = Red; else color_3 = Blue;

if(sym_4 85) color_4 = Red; else color_4 = Blue;
 

"bar" is shift from current bar:

0 - for current(open) bar

1 - previous ("closed") bar.

grstaka:
Thank You!!!! Whats the bar mean? Is that +1 -1 Bar?
 

Thanks for your Help Roger, appreciate it

 

Help creating an ob/os indicator

I'm looking for someone with coding skills to help me create an over-bought/over-sold indicator that would take take the price difference of 2 pairs and display the result. Should be pretty straight forward but then I'm not a programmer so I'm not exactly sure. Any one interested in trying this for me? If so let me know or if someone knows of one already that would be great too. I've searched but haven't seen anything that will do this.

 

Pips until margin call

Does anyone know a way to figure out the number of pips an order can go until one gets margin called on the position? Assuming only one position open at a time.

I'm sure there's a way, but I haven't been able to figure it out.

 

Alert signals tuned to trade- How to do that ?

Hi,

I have an indicator that displays trade arrows, blue for Buy & Pink for sell. I need actual Buy order & sell order alongwith sound signal . Hence there is only 1 trade for a pair at all times and current trade closes when opposite arrow hows and also a new trade as per the arrow . Where & how do I modify the code. Attaching the code herewith. Thanks for your help.

/*

+------------------------------------------------------------------+

| |

+------------------------------------------------------------------+

*/

#property copyright "Copyright)"

#property link "http://"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 DodgerBlue

#property indicator_width1 3

#property indicator_color2 Magenta

#property indicator_width2 3

extern string note1 = "First Moving Average";

extern int MA1 = 10;

extern string note2 = "0=sma, 1=ema, 2=smma, 3=lwma";

extern int MA1Mode = 0; //0=sma, 1=ema, 2=smma, 3=lwma

extern string note3 = "--------------------------------------------";

extern string note4 = "Second Moving Average";

extern int MA2 = 50;

extern string note5 = "0=sma, 1=ema, 2=smma, 3=lwma";

extern int MA2Mode = 0; //0=sma, 1=ema, 2=smma, 3=lwma

extern string note6 = "--------------------------------------------";

extern string note7 = "Arrow Type";

extern string note8 = "0=Thick, 1=Thin, 2=Hollow, 3=Round";

extern string note9 = "4=Fractal, 5=Diagonal Thin";

extern string note10 = "6=Diagonal Thick, 7=Diagonal Hollow";

extern string note11 = "8=Thumb, 9=Finger";

extern int ArrowType=2;

extern string note12 = "--------------------------------------------";

extern string note13 = "turn on Alert = true; turn off = false";

extern bool AlertOn = true;

extern string note14 = "--------------------------------------------";

extern string note15 = "send Email Alert = true; turn off = false";

extern bool SendAnEmail=false;

double CrossUp[];

double CrossDown[];

string AlertPrefix, MA1short_name, MA2short_name;

string GetTimeFrameStr() {

switch(Period())

{

case 1 : string TimeFrameStr="M1"; break;

case 5 : TimeFrameStr="M5"; break;

case 15 : TimeFrameStr="M15"; break;

case 30 : TimeFrameStr="M30"; break;

case 60 : TimeFrameStr="H1"; break;

case 240 : TimeFrameStr="H4"; break;

case 1440 : TimeFrameStr="D1"; break;

case 10080 : TimeFrameStr="W1"; break;

case 43200 : TimeFrameStr="MN1"; break;

default : TimeFrameStr=Period();

}

return (TimeFrameStr);

}

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

if (ArrowType == 0) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 233);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 234);

}

else if (ArrowType == 1) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 225);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 226);

}

else if (ArrowType == 2) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 241);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 242);

}

else if (ArrowType == 3) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 221);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 222);

}

else if (ArrowType == 4) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 217);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 218);

}

else if (ArrowType == 5) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 228);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 230);

}

else if (ArrowType == 6) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 236);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 238);

}

else if (ArrowType == 7) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 246);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 248);

}

else if (ArrowType == 8) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 67);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 68);

}

else if (ArrowType == 9) {

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0, 71);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1, 72);

}

SetIndexBuffer(0, CrossUp);

SetIndexBuffer(1, CrossDown);

//---- indicator short name

switch(MA1Mode)

{

case 1 : MA1short_name="EMA"; break;

case 2 : MA1short_name="SMMA"; break;

case 3 : MA1short_name="LWMA"; break;

default :

MA1Mode=0;

MA1short_name="SMA";

}

switch(MA2Mode)

{

case 1 : MA2short_name="EMA"; break;

case 2 : MA2short_name="SMMA"; break;

case 3 : MA2short_name="LWMA"; break;

default :

MA2Mode=0;

MA2short_name="SMA";

}

AlertPrefix=Symbol()+" ("+GetTimeFrameStr()+"): ";

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

bool NewBar()

{

static datetime lastbar;

datetime curbar = Time[0];

if(lastbar!=curbar)

{

lastbar=curbar;

return (true);

}

else

{

return(false);

}

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start() {

int limit, i, counter;

double MA1now, MA2now, MA1previous, MA2previous, MA1after, MA2after;

double Range, AvgRange;

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++) {

counter=i;

Range=0;

AvgRange=0;

for (counter=i ;counter<=i+9;counter++)

{

AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);

}

Range=AvgRange/10;

MA1now = iMA(NULL, 0, MA1, 0, MA1Mode, PRICE_CLOSE, i);

MA1previous = iMA(NULL, 0, MA1, 0, MA1Mode, PRICE_CLOSE, i+1);

MA1after = iMA(NULL, 0, MA1, 0, MA1Mode, PRICE_CLOSE, i-1);

MA2now = iMA(NULL, 0, MA2, 0, MA2Mode, PRICE_CLOSE, i);

MA2previous = iMA(NULL, 0, MA2, 0, MA2Mode, PRICE_CLOSE, i+1);

MA2after = iMA(NULL, 0, MA2, 0, MA2Mode, PRICE_CLOSE, i-1);

if ((MA1now > MA2now) && (MA1previous MA2after)) {

CrossUp = Low - Range*1.5;

if ( NewBar())

{

if (AlertOn) {

Alert(AlertPrefix+MA1short_name+" ("+MA1+") "+"crosses UP " + MA2short_name+" ("+MA2+")");

}

if (SendAnEmail) {

SendMail(AlertPrefix,MA1short_name+" ("+MA1+") "+"crosses UP " + MA2short_name+" ("+MA2+")");

}

}

}

else if ((MA1now MA2previous) && (MA1after < MA2after)) {

CrossDown = High + Range*1.5;

if (NewBar())

{

if (AlertOn) {

Alert(AlertPrefix+MA1short_name+" ("+MA1+") "+"crosses DOWN " + MA2short_name+" ("+MA2+")");

}

if (SendAnEmail) {

SendMail(AlertPrefix,MA1short_name+" ("+MA1+") "+"crosses DOWN " + MA2short_name+" ("+MA2+")");

}

}

}

}

return(0);

}

 

Looks like a simple MA cross indicator. Check the link in my sig for a free tutorial that will enable you to build an MA cross EA.

Good luck

Lux

 

Hello seniore the EA can make the robot.. model also martiangle

1.Looping -> Set the robot how many times the way round

2.First Order Auto -> Order buy or sell based on the trend of the small market at that time, then auto op next to the last buy or sell.

3.Start lot -> set lot

4.Range -> The distance between the position you order one with the other position

5.Rangeincrease--> development of the distance between the position of the other one with the other positions in accordance with multiple growth

6.Start level increase -> dibaris order to enable the function parameters rangeincrease

7.Multiplier -> multiplication lot in next order

8.TPmoney -> close all orders when reached profit of the money at that time.

thank

 

Help EA

mirak:
Hello seniore the EA can make the robot.. model also martiangle

1.Looping -> Set the robot how many times the way round

2.First Order Auto -> Order buy or sell based on the trend of the small market at that time, then auto op next to the last buy or sell.

3.Start lot -> set lot

4.Range -> The distance between the position you order one with the other position

5.Rangeincrease--> development of the distance between the position of the other one with the other positions in accordance with multiple growth

6.Start level increase -> dibaris order to enable the function parameters rangeincrease

7.Multiplier -> multiplication lot in next order

8.TPmoney -> close all orders when reached profit of the money at that time.

thank

Uppp plsss

 

iTime

here is code to get Bar's begin time working on MTF

GetTime =(iTime(Symbol(),60,i)); its OK

how we get Bar's end time ?

Thanks