Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information
int init() { SetIndexBuffer(0,oscBuffer); IndicatorShortName("Osc ("+OscPeriod+")"); return(0); } int deinit() { return(0); } int start() { int counted_bars=IndicatorCounted(); int i,limit;
if (high!=low) double raw = 100.00*(price-low)/(high-low); else raw = 0.00; oscBuffer[i]= oscBuffer[i+1]*2.0/3.0 + raw/3.0; } return(0); }
But, take a look at the picture too : upper is "Oscar" lower is Ema(5) of stochastic(8), or to make it even simpler, on the bottom is Stochastic(8,5,1) with signal line set to exponential. So "Oscar" is simply a signal line of the stochastic
I'm in need of some disparate help here. I've got some code that will look for an agreement between different indicators. Once they all agree I want a way for the trades to enter in the way I described it in the chart images. So far I can enter the 1st "Buy" trade but it doesn't enter just 1 trade....it's entering up to 8 trades. And then, if the market goes against me I enter a "contingency trade" where I'm buy/selling again despite that its going against me. I would greatly appreciate if someone could show me what the correct code should look like
Not sure if these images will show but just in case I also have them as attachments.
Here is my flawed code that is supposed to execute the trade...
while (execute_trade ==5)
{if ( OrdersTotal() == buy_trade1 ) //buy_trade1 = 1...this stops it after 1 order have been placed...but doesnt work yet
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
execute_trade=0;
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("My ticket is: " , ticket);
{
buy1 = OrderOpenPrice(); //taking the 1st order's price and pushing it into this variable
// Comment("order #1 open price is ", OrderOpenPrice() + " " + buy1 + " less than " + (buy1-0.0030));
if (buy1 >= (buy1-0.0030))
{
//if ( OrdersTotal() <= buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
//execute_trade=0;
}
}
else
Print("OrderSelect returned the error of ",GetLastError());
I'm in need of some disparate help here. I've got some code that will look for an agreement between different indicators. Once they all agree I want a way for the trades to enter in the way I described it in the chart images. So far I can enter the 1st "Buy" trade but it doesn't enter just 1 trade....it's entering up to 8 trades. And then, if the market goes against me I enter a "contingency trade" where I'm buy/selling again despite that its going against me. I would greatly appreciate if someone could show me what the correct code should look like
Not sure if these images will show but just in case I also have them as attachments. Pic 1 Pic 2
Here is my flawed code that is supposed to execute the trade...
while (execute_trade ==5)
{if ( OrdersTotal() == buy_trade1 ) //buy_trade1 = 1...this stops it after 1 order have been placed...but doesnt work yet
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
execute_trade=0;
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("My ticket is: " , ticket);
{
buy1 = OrderOpenPrice(); //taking the 1st order's price and pushing it into this variable
// Comment("order #1 open price is ", OrderOpenPrice() + " " + buy1 + " less than " + (buy1-0.0030));
if (buy1 >= (buy1-0.0030))
{
//if ( OrdersTotal() <= buy_trade1 ) //this stops it after 1 order have been placed.
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point);
//execute_trade=0;
}
}
else
Print("OrderSelect returned the error of ",GetLastError());
Want to open 1 POSITION in a direction but No more even if position hits TP.
Checking for open position won't work obviously.
Example-
I don't want another 'BUY' to execute if i had a buy open and it hit the TP. I want it to wait until the MA's cross down and open a SELL with a TP and repeat the whole thing over again.
There's probably an easy way to do this buy my brain is fried or something
THANK YOU
__________________ www.LiveTeamTrading.com
The FIRST LIVE Team trading Network Community for FOREX TRADERS! Ask me about Getting an Invite!
if(ord>0) return (0); //Abort! A Position For This Pair is Already Open
//the rest of my program code
}
I've found in reality, I've had to use pauses for a couple seconds in the code due to brokers not instantly opening positions.
Thank you for taking your time to show me this code! I don't think my screen shots were sufficient to explain the logic of what I'm trying to achieve. Here's the explanation in witting...and just as an example I am using a "Buy" scenario. Eventually I would like it to do both "Buy" and "Sell"
Scenario 1: If your buy trade goes with you... --Trade 1, T/P at 70 pips
--Trade 2, 30 pips appart from trade 1, T/P at 70 pips
--Trade 3, 30 pips away from trade 2, T/P at 70 pips
** 210 pips total
Scenario 2: If your buy trade goes against you...put in a trade every 60 pips for three trades and wait for the market to pull back in your direction --trade 1 bad...enter new contingency buy trade at -60 pips from the price of trade 1.
--trade 2 bad...enter new contingency buy trade at -60 pips from the price of trade 2.
--trade 3 bad...enter no more trades
--wait for reversal signs...parabolic dot = bottom...if looks like its moving in our direction then enter a 4th buy
--wait 30 more positive pips then enter 5th buy trade...continue to enter buy trades (6, 7, 8 trade) until it reaches the level that the 3rd contingency trade was at....then wait for the original first 1, and follow the steps of scenario 1.
Is it possible to get the code for this logic? I would be greatly appreciative!!!
Want to open 1 POSITION in a direction but No more even if position hits TP.
Checking for open position won't work obviously.
Example-
I don't want another 'BUY' to execute if i had a buy open and it hit the TP. I want it to wait until the MA's cross down and open a SELL with a TP and repeat the whole thing over again.
There's probably an easy way to do this buy my brain is fried or something
THANK YOU
You need to check your order history to see if an order just closed on the current bar for profit.
i want add this condition to my ea
if loss in curent day = 100 ---> close al position, dont take any OP until tomorow
if loss in curent day < 100 ---> may take any OP
anybody can help ???
this my EA
Code:
//+------------------------------------------------------------------+
/*
EA Dengan sinyal dari signal ma
*/
extern double Lots = 0.01;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double a1, //ma 10 tf 4h
a2, //ma 10 tf 1h
a3, //ma 10 tf 15m
a4, //ma 10 tf 5m
j, //yesterday low price
k, //yesterday high price
b1, //ma 30 tf 4h
b2, //ma 30 tf 1h
b3, //ma 30 tf 15m
b4; //ma 30 tf 5m
int cnt, ticket, total;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
// to simplify the coding and speed up access
// data are put into internal variables
a1 = iMA(NULL,240,10,0,MODE_EMA,PRICE_CLOSE,0);
a2 = iMA(NULL,60,10,0,MODE_EMA,PRICE_CLOSE,0);
a3 = iMA(NULL,15,10,0,MODE_EMA,PRICE_CLOSE,0);
a4 = iMA(NULL,5,10,0,MODE_EMA,PRICE_CLOSE,0);
b1 = iMA(NULL,240,30,0,MODE_EMA,PRICE_CLOSE,0);
b2 = iMA(NULL,60,30,0,MODE_EMA,PRICE_CLOSE,0);
b3 = iMA(NULL,15,30,0,MODE_EMA,PRICE_CLOSE,0);
b4 = iMA(NULL,5,30,0,MODE_EMA,PRICE_CLOSE,0);
j = iLow(NULL,60,2);
k = iHigh(NULL,60,2);
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(a1>b1&&
a2>b2&&
a3>b3&&
a4>b4+10*Point)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"macd sample",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
// check for short position (SELL) possibility
if(a1<b1&&
a2<b2&&
a3<b3&&
a4<b4-10*Point)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"macd sample",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
// it is important to enter the market correctly,
// but it is more important to exit it correctly...
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(Bid>OrderOpenPrice()+100*Point)//if profit > 100
{
OrderModify(OrderTicket(),OrderOpenPrice(),j,0,0,Green);
return(0);
}
if(Bid<OrderOpenPrice()-150*Point)//stop loss
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
return(0); // exit
}
}
else // go to short position
{
// should it be closed?
if(Ask<OrderOpenPrice()-100*Point)//if profit > 100
{
OrderModify(OrderTicket(),OrderOpenPrice(),k,0,0,Green);
return(0);
}
if(Ask>OrderOpenPrice()+150*Point)//stop loss
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
return(0); // exit
}
}
}
}
return(0);
}
// the end.