NexusFi: Find Your Edge


Home Menu

 





Buy / Sell Code Problem


Discussion in Platforms and Indicators

Updated
    1. trending_up 2,415 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 resirca52009 
Indianapolis, Indiana/ USA
 
Experience: Advanced
Platform: MT4, Ninjatrader
Broker: AMP / CQG
Trading: Futures
Posts: 64 since Oct 2012
Thanks Given: 112
Thanks Received: 35

Hello,

I have learned a great deal from this site over the past few weeks but unfortunately still feel dwarfed by the amount of knowledge I find here. Not only feel embarrassed to answer a question but more so to ask one. Any way here it is :

Below is my buy / sell code ( based on John Ehlers Center of Gravity Indicator ) Something is just not right; it buys and sells OK but I can't test it in the strategy tester...all results come back insignificant. Any help is much appreciated.

//************GO LONG

if ( (iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 1, 1) > iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 2, 1) && iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 1, 3) > iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 0, 3)) )
{ Print("Trading condition [(iCustom(Symbol(), 0, Center Of Gravity Oscillator...] is valid. Trying to open long position...");
Buy(Symbol(), 0.01, 30, 15, 15); }

//************EXIT LONG

if ( (iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 1, 1) < iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 2, 1) && iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 1, 3) < iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 0, 3)) )
{ Print("Trading condition [(iCustom(Symbol(), 0, Center Of Gravity Oscillator...] is valid. Trying to close long position...");
CloseLong(Symbol()); }

//************GO SHORT

if ( (iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 1, 1) < iCustom(Symbol(), 1, "Center Of Gravity Oscillator",8,true, 2, 1) && iCustom(Symbol(), 1, "Center Of Gravity Oscillator",8,true, 0, 3) < iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 0, 3)) )
{ Print("Trading condition [(iCustom(Symbol(), 0, Center Of Gravity Oscillator...] is valid. Trying to open long position...");
Sell(Symbol(), 0.01, 30, 15, 15); }

//************EXIT SHORT

if ( (iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 1, 1) > iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 2, 1) && iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 0, 3) > iCustom(Symbol(), 0, "Center Of Gravity Oscillator",8,true, 0, 3)) )
{ Print("Trading condition [(iCustom(Symbol(), 0, Center Of Gravity Oscillator...] is valid. Trying to close short position...");
CloseShort(Symbol()); }


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
CFTC Workforce Shrinks 24% to 15-Year Low While Predicti …
Traders Hideout
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
NYSE Owner ICE Invests in Crypto Exchange OKX at $25 Bil …
Cryptocurrency
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,951 since Dec 2010
Thanks Given: 3,042
Thanks Received: 2,397


resirca52009 View Post
Hello,


Below is my buy / sell code ( based on John Ehlers Center of Gravity Indicator ) Something is just not right; it buys and sells OK but I can't test it in the strategy tester...all results come back insignificant. Any help is much appreciated.

Hi @resirca52009,

Is it possible that indicator needs TickData? If so, you can probably only test it under Replay mode. Back testing and strategy testing only provides bar data, not tick data, back to the strategy.


Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: [wiki=NT-Local-Order-Manager-LOM-Guide][/wiki]
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,951 since Dec 2010
Thanks Given: 3,042
Thanks Received: 2,397


Sorry,

I am not sure my message above is relevant, I don't know anything about MetaTrader, I was thinking the question was about NinjaTrader.


Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: [wiki=NT-Local-Order-Manager-LOM-Guide][/wiki]
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 resirca52009 
Indianapolis, Indiana/ USA
 
Experience: Advanced
Platform: MT4, Ninjatrader
Broker: AMP / CQG
Trading: Futures
Posts: 64 since Oct 2012
Thanks Given: 112
Thanks Received: 35


NJAMC View Post
Hi @resirca52009,

Is it possible that indicator needs TickData? If so, you can probably only test it under Replay mode. Back testing and strategy testing only provides bar data, not tick data, back to the strategy.

NJAMC,

Thanks for the reply & links; I'll review it.......


Started this thread Reply With Quote




Last Updated on November 12, 2012


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts