NexusFi: Find Your Edge


Home Menu

 





Buy / Sell Code Problem


Discussion in Platforms and Indicators

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




 
Search this Thread

Buy / Sell Code Problem

  #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?
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Deepmoney LLM
Elite Quantitative GenAI/LLM
 
  #2 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394


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: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394


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: NT-Local-Order-Manager-LOM-Guide
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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts